#include <zlib.h>
#include <fmt/format.h>
#include <iostream>

#define INFOLN(...) std::cout << fmt::format(__VA_ARGS__) << std::endl

int main(int argc, char *argv[]) {
    unsigned char strSrc[] = "hello world, aaaa bbbb cccc";
    unsigned char buf[1024] = {0};
    unsigned char strDst[1024] = {0};
    unsigned long srcLen = sizeof(strSrc);
    unsigned long bufLen = sizeof(buf);
    unsigned long dstLen = sizeof(strDst);

    INFOLN("Src string : {}\n Length: {}\n", strSrc, srcLen);

    /*压缩*/
    compress(buf, &bufLen, strSrc, srcLen);
    INFOLN("after compressed Length: {}\n", bufLen);

    INFOLN("compressed string {}\n", buf);
    /*解压缩*/
    uncompress(strDst, &dstLen, buf, bufLen);
    INFOLN("after uncompressed length: {}\n", dstLen);

    INFOLN("Uncompressed string {}\n", strDst);
    return 0;
}